package ms.shop.dao;

import mapper.MsMapper;
import ms.shop.entity.Classify;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface ClassifyDAO extends MsMapper<Classify> {

    @Select("<script>"
            + "select * from t_classify "
            + "where 1=1 "
            + "<if test=\"name != null and  name!= '' \"> and name like '%${name}%' </if> "
            + "<if test=\"pid != 0 \"> and pid=#{pid} </if> "
            + "<if test=\"status != 0 \"> and status=#{status} </if> "
            + "<if test=\"status == 0 \"> and status != 0 </if> "
            + "order by create_time desc"
            + "</script>")
    @ResultType(Classify.class)
    List<Classify> queryClassifys(@Param("name") String name, @Param("pid") Long pid, @Param("status") Integer status);
}
